package cn.iocoder.yudao.module.design.dal.mysql.houseUserRel;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.house.vo.HouseTaskStaticResVO;
import cn.iocoder.yudao.module.design.controller.admin.house.vo.HouseTwoUserReqVO;
import cn.iocoder.yudao.module.design.controller.admin.houseUserRel.vo.HouseUserRelExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.houseUserRel.vo.HouseUserRelPageReqVO;
import cn.iocoder.yudao.module.design.controller.admin.houseUserRel.vo.UserRelListVO;
import cn.iocoder.yudao.module.design.dal.dataobject.houseUserRel.HouseUserRelDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 住宅相关用户关联 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface HouseUserRelMapper extends BaseMapperX<HouseUserRelDO> {

    default PageResult<HouseUserRelDO> selectPage(HouseUserRelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HouseUserRelDO>()
                .eqIfPresent(HouseUserRelDO::getUserId, reqVO.getUserId())
                .eqIfPresent(HouseUserRelDO::getHouseId, reqVO.getHouseId())
                .eqIfPresent(HouseUserRelDO::getAddFlg, reqVO.getAddFlg())
                .eqIfPresent(HouseUserRelDO::getRemoveFlg, reqVO.getRemoveFlg())
                .eqIfPresent(HouseUserRelDO::getModifyFlg, reqVO.getModifyFlg())
                .eqIfPresent(HouseUserRelDO::getQueryFlg, reqVO.getQueryFlg())
                .eqIfPresent(HouseUserRelDO::getStatus, reqVO.getStatus())
                .orderByDesc(HouseUserRelDO::getId));
    }

    default List<HouseUserRelDO> selectList(HouseUserRelDO reqVO) {
        return selectList(new LambdaQueryWrapperX<HouseUserRelDO>()
                .eqIfPresent(HouseUserRelDO::getUserId, reqVO.getUserId())
                .eqIfPresent(HouseUserRelDO::getHouseId, reqVO.getHouseId())
                .inIfPresent(HouseUserRelDO::getStatus, reqVO.getStatus())
                .eqIfPresent(HouseUserRelDO::getRoleId, reqVO.getRoleId())
                .orderByDesc(HouseUserRelDO::getId));
    }

    default List<HouseUserRelDO> selectList(HouseUserRelExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<HouseUserRelDO>()
                .eqIfPresent(HouseUserRelDO::getUserId, reqVO.getUserId())
                .eqIfPresent(HouseUserRelDO::getHouseId, reqVO.getHouseId())
                .eqIfPresent(HouseUserRelDO::getAddFlg, reqVO.getAddFlg())
                .eqIfPresent(HouseUserRelDO::getRemoveFlg, reqVO.getRemoveFlg())
                .eqIfPresent(HouseUserRelDO::getModifyFlg, reqVO.getModifyFlg())
                .eqIfPresent(HouseUserRelDO::getQueryFlg, reqVO.getQueryFlg())
                .eqIfPresent(HouseUserRelDO::getStatus, reqVO.getStatus())
                .orderByDesc(HouseUserRelDO::getId));
    }
    List<UserRelListVO>  getHouseUserRelListByHouseIdAndRoleId(@Param("houseId") Long houseId, @Param("roleId")Long roleId,@Param("userId")Long userId);

    List<UserRelListVO>  getHouseUserRelListGroupConcatRoleName(@Param("houseId") Long houseId, @Param("roleId")Long roleId,@Param("userId")Long userId);


    /**
     * 查询项目内用户角色
     * @author Annie
     * @time 2023/8/11 15:53
     * @param[1] houseId
     * @return List<String>
     */
    List<String> getHouseRolesByHouseIdAndUserId(@Param("houseId") Long houseId,@Param("userId") Long userId);

    List<HouseTaskStaticResVO> getHouseTaskStaticByUserId(Long id);

    List<HouseTwoUserReqVO> getHouseTwoUserList(@Param("houseId")Long houseId, @Param("roleList")List<Long> roleList);
}
